/**
 * submitFeedback 提交意见反馈
 */

const feedbackStatement = require("../../common/sql_sentences/feedback")

exports.submitFeedback = async (req, res) => {
  try {
    const info = req.auth
    // 提交意见反馈
    const sqlStr = feedbackStatement.insert({
      ...req.body,
      f_number: info.type === 1 ? info.s_number : info.job_number,
      type: info.type === 1 ? '学生' : '维修人员',
      name: info.name
    })
    let results = await RunSQL(sqlStr)
    if (results.affectedRows !== 1) return res.successSend("提交意见反馈失败！", 10005)
    return res.successSend("提交意见反馈成功！")
  } catch (error) {
    res.errSend(error)
  }
}
